---
title: 'Replication Materials for Dür et al.'
author: A. Dür, Robert A. Huber, Gemma Mateo, Gabriele Spilker
output:
  rmdformats::downcute:
    self_contained: true
    thumbnails: true
    lightbox: true
    gallery: false
    highlight: tango
editor_options:
  chunk_output_type: console
---

```{r globopt, include = F}
knitr::opts_chunk$set(warning = FALSE)
```

This is the readme file accompanying the replication material for the publication: Dür et al. Interest Group Preferences towards Trade Agreements: Institutional Design Matters <i>Interest Groups & Advocacy</i>. DOI: <https://doi.org/10.1057/s41309-022-00174-z>. In this notebook, we explain the replication of our analysis in detail. 

# How to proceed

First download all files available from the Harvard Dataverse (see <https://doi.org/10.7910/DVN/UJGMAW>) in a folder of choice. The next steps of the analysis are outlined in the script below.

# Prepare analysis

First download all files from the project file "Replication_IGA.Rproj" to a folder of your choice. Open it in R-Studio and load the "README.Rmd" file. The next lines of code automatically set the working directory. 

```{r}
# Set wd with here() package

here::i_am("Replication_IGA.Rproj")

# Clean Environment
rm(list = ls())
```

The files should cover the following:

```{r}
#List of files
list.files() #
list.files("./data/")
list.files("./output/")
list.files("./rcode/")
```

Please ensure the folder structure is the same on your local device. Downloading the files <i>should</i> create the structure locally.

# Opening the main R script (master.R)

Open the R-Script "master.R" from rcode. It loads all relevant scripts. From this script, you can run the subsequent R-Scripts from the folder rcode following the order of the "master.R" file. Please proceed as follows:

1. "response_behaviour.R": This code creates the information on the response rate displayed in Figure A1 and Table A3. 
2. "preparing_experimental_data.R": This script prepares the dataset and creates a dataframe df_exp, which is used in the subsequent analyses of the experiment. It must be run before "descriptives.R" and "analysis.R"
3. "descriptives.R" creates descriptive information on the dataset which is displayed in Figure 1 and Tables A1 and A2.
4. "analysis.R" runs all regression models and creates subsequent regression tables and figures. 
  + This script loads to ancillary scripts "prepTex.R" and "prepTexglm.R" which allow extracting the central information to textreg.


```{r, echo=FALSE}
source("./rcode/master.R")
```

# Session Info

This notebook was run using the following setup:

```{r}
pander::pander(sessionInfo())
```
